// Decompiled by Jad v1.5.8g. Copyright 2001 Pavel Kouznetsov.
// Jad home page: http://www.kpdus.com/jad.html
// Decompiler options: packimports(3) 

package com.sec.android.app.calculator;

import android.widget.BaseAdapter;
import java.io.*;
import java.util.Iterator;
import java.util.Vector;

// Referenced classes of package com.sec.android.app.calculator:
//            HistoryEntry

class History
{

    History()
    {
        mEntries = new Vector();
        clear();
    }

    History(int i, DataInput datainput)
        throws IOException
    {
        mEntries = new Vector();
        if(i >= 1)
        {
            int j = datainput.readInt();
            for(int k = 0; k < j; k++)
                mEntries.add(new HistoryEntry(i, datainput));

            mPos = datainput.readInt();
            return;
        } else
        {
            throw new IOException((new StringBuilder()).append("invalid version ").append(i).toString());
        }
    }

    private void notifyChanged()
    {
        if(mObserver != null)
            mObserver.notifyDataSetChanged();
    }

    void clear()
    {
        mEntries.clear();
        mEntries.add(new HistoryEntry("", ""));
        mPos = 0;
        notifyChanged();
    }

    HistoryEntry current(int i)
    {
        return (HistoryEntry)mEntries.elementAt(i);
    }

    void enter(String s, String s1)
    {
        if(mEntries.size() > 10)
            mEntries.remove(0);
        int i = mEntries.size();
        if(mEntries.size() == 0)
            i = 1;
        mEntries.insertElementAt(new HistoryEntry(s, s1), i - 1);
        mPos = mEntries.size() - 1;
        notifyChanged();
    }

    public boolean isHistory()
    {
        boolean flag;
        if(current(0).toString().length() == 0 || mEntries.size() == 0)
            flag = false;
        else
            flag = true;
        return flag;
    }

    void write(DataOutput dataoutput)
        throws IOException
    {
        dataoutput.writeInt(mEntries.size());
        for(Iterator iterator = mEntries.iterator(); iterator.hasNext(); ((HistoryEntry)iterator.next()).write(dataoutput));
        dataoutput.writeInt(mPos);
    }

    Vector mEntries;
    BaseAdapter mObserver;
    int mPos;
}
